<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="div1" class="class-div1">
        <p id="p1" data-name="p1-data-name">this is p1</p>
        <p id="p2">this is p2</p>
    </div>
    <div id="div2">
        <p id="p3">this is p3</p>
        <p id="p4">this is p4</p>
    </div>
    <script type="text/javascript">
        var div = document.getElementById('div1')
        // property
        console.log(div.className)
        div1.className = 'abc'
        console.log(div.className)
        

        // attr
        var p1 = document.getElementById('p1')
        console.log(p1.getAttribute('data-name'))
        p1.setAttribute('data-name','xyz')
    </script>
</body>
</html>